#ifndef ANIMWIDGET_H
#define ANIMWIDGET_H

#include <QWidget>
#include <QMap>
#include <QMultiMap>
#include <QVector>
#include <animbase.h>

class AnimWidget : public QWidget
{
    Q_OBJECT
public:
    explicit AnimWidget(QWidget *parent = nullptr);

    void PrepareOpMap(QMultiMap<double, AnimOp> &, double startPos);
    void Clear();
    void SetFrameTime(double t) { mFrameTime = t; }

protected:
    void paintEvent(QPaintEvent*) override;
    void timerEvent(QTimerEvent*) override;

private:
    QMap<double, QVector<AnimOp>> mOpMap;
    QMap<QString, QImage> mImageCache;
    QMap<QString, AnimEntity> mEntities;

    double mFrameTime, mNow;

    QList<double> mTaskTimeQueue;

    QString mResourceDir;

private:
    void progressAnimation();
    void ExecuteOp(AnimOp&);
    QImage* GetImage(QString);

public slots:
    void SetResourceDir(QString);

signals:

};

#endif // ANIMWIDGET_H
